Proper connect_port
[juce-lv2.git] / juce / source / extras / the jucer / src / model / paintelements / jucer_PaintElementPath.h
blob40290e0c0ee76da2337158be498f94449521117f
1 /*
2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #ifndef __JUCER_PAINTELEMENTPATH_JUCEHEADER__
27 #define __JUCER_PAINTELEMENTPATH_JUCEHEADER__
29 #include "jucer_ColouredElement.h"
30 #include "jucer_ElementSiblingComponent.h"
31 class PathPointComponent;
32 class PaintElementPath;
35 //==============================================================================
36 /**
38 class PathPoint
40 public:
41 //==============================================================================
42 PathPoint (PaintElementPath* const owner);
43 PathPoint (const PathPoint& other);
44 PathPoint& operator= (const PathPoint& other);
45 ~PathPoint();
47 //==============================================================================
48 PaintElementPath* owner;
50 Path::Iterator::PathElementType type;
52 RelativePositionedRectangle pos [3];
54 //==============================================================================
55 int getNumPoints() const;
57 void changePointType (const Path::Iterator::PathElementType newType,
58 const Rectangle<int>& parentArea,
59 const bool undoable);
61 void deleteFromPath();
62 void getEditableProperties (Array <PropertyComponent*>& properties);
64 private:
65 const PathPoint withChangedPointType (const Path::Iterator::PathElementType newType,
66 const Rectangle<int>& parentArea) const;
70 //==============================================================================
71 /**
73 class PaintElementPath : public ColouredElement
75 public:
76 //==============================================================================
77 PaintElementPath (PaintRoutine* owner);
78 ~PaintElementPath();
80 //==============================================================================
81 void setInitialBounds (int parentWidth, int parentHeight);
82 const Rectangle<int> getCurrentBounds (const Rectangle<int>& parentArea) const;
83 void setCurrentBounds (const Rectangle<int>& b, const Rectangle<int>& parentArea, const bool undoable);
85 //==============================================================================
86 bool getPoint (int index, int pointNumber, double& x, double& y, const Rectangle<int>& parentArea) const;
87 void movePoint (int index, int pointNumber, double newX, double newY, const Rectangle<int>& parentArea, const bool undoable);
89 const RelativePositionedRectangle getPoint (int index, int pointNumber) const;
90 void setPoint (int index, int pointNumber, const RelativePositionedRectangle& newPoint, const bool undoable);
92 int getNumPoints() const throw() { return points.size(); }
93 PathPoint* getPoint (int index) const throw() { return points [index]; }
94 int indexOfPoint (PathPoint* const p) const throw() { return points.indexOf (p); }
96 PathPoint* addPoint (int pointIndexToAddItAfter, const bool undoable);
97 void deletePoint (int pointIndex, const bool undoable);
99 void pointListChanged();
101 int findSegmentAtXY (int x, int y) const;
103 //==============================================================================
104 bool isSubpathClosed (int pointIndex) const;
105 void setSubpathClosed (int pointIndex, const bool closed, const bool undoable);
107 bool isNonZeroWinding() const throw() { return nonZeroWinding; }
108 void setNonZeroWinding (const bool nonZero, const bool undoable);
110 //==============================================================================
111 void getEditableProperties (Array <PropertyComponent*>& properties);
113 void fillInGeneratedCode (GeneratedCode& code, String& paintMethodCode);
115 //==============================================================================
116 static const char* getTagName() throw() { return "PATH"; }
117 XmlElement* createXml() const;
118 bool loadFromXml (const XmlElement& xml);
120 void setToPath (const Path& p);
122 //==============================================================================
123 void draw (Graphics& g, const ComponentLayout* layout, const Rectangle<int>& parentArea);
124 void drawExtraEditorGraphics (Graphics& g, const Rectangle<int>& relativeTo);
126 void resized();
127 void parentSizeChanged();
129 void mouseDown (const MouseEvent& e);
130 void mouseDrag (const MouseEvent& e);
131 void mouseUp (const MouseEvent& e);
133 void createSiblingComponents();
134 void changed();
136 private:
137 friend class PathPoint;
138 friend class PathPointComponent;
139 OwnedArray <PathPoint> points;
140 bool nonZeroWinding;
141 mutable Path path;
142 mutable Rectangle<int> lastPathBounds;
143 int mouseDownOnSegment;
144 bool mouseDownSelectSegmentStatus;
146 const String pathToString() const;
147 void restorePathFromString (const String& s);
148 void updateStoredPath (const ComponentLayout* layout, const Rectangle<int>& parentArea) const;
149 int getBorderSize() const;
151 void rescalePoint (RelativePositionedRectangle& pos, int dx, int dy,
152 double scaleX, double scaleY,
153 double scaleStartX, double scaleStartY,
154 const Rectangle<int>& parentArea) const;
158 //==============================================================================
161 class PathPointComponent : public ElementSiblingComponent
163 public:
164 //==============================================================================
165 PathPointComponent (PaintElementPath* const path_,
166 const int index, const int pointNumber);
168 ~PathPointComponent();
170 //==============================================================================
171 void updatePosition();
172 void showPopupMenu();
174 //==============================================================================
175 void paint (Graphics& g);
176 void mouseDown (const MouseEvent& e);
177 void mouseDrag (const MouseEvent& e);
178 void mouseUp (const MouseEvent& e);
180 void changeListenerCallback (ChangeBroadcaster*);
182 private:
183 PaintElementPath* const path;
184 PaintRoutine* const routine;
185 const int index;
186 const int pointNumber;
187 int dragX, dragY;
188 bool selected, dragging, mouseDownSelectStatus;
192 #endif // __JUCER_PAINTELEMENTPATH_JUCEHEADER__